﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LearnPay
{
    /// <summary>
    /// 返回信息
    /// </summary>
    public class FuncResult
    {
        /// <summary>
        /// 提示内容
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 异常编码数字值
        /// </summary>
        public int StatusCode { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success { get; set; }

        /// <summary>
        /// 正确
        /// </summary>
        /// <returns></returns>
        public static FuncResult SuccessResult()
        {
            return new FuncResult() { Success = true };
        }

        /// <summary>
        /// 正确
        /// </summary>
        /// <returns></returns>
        public static FuncResult SuccessResult(string message)
        {
            return new FuncResult() { Success = true, Message = message };
        }

        /// <summary>
        /// 正确
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="content"></param>
        /// <returns></returns>
        public static FuncResult<T> SuccessResult<T>(T content)
        {
            return new FuncResult<T>() { Content = content, Success = true };
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="message"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public static FuncResult FailResult(string message, int statusCode = 0)
        {
            return new FuncResult() { Message = message, StatusCode = statusCode, Success = false };
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public static FuncResult<T> FailResult<T>(string message, int statusCode = 0)
        {
            return new FuncResult<T>() { Content = default(T), Message = message, StatusCode = statusCode, Success = false };
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="content"></param>
        /// <param name="message"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public static FuncResult<T> FailResult<T>(T content, string message, int statusCode = 0)
        {
            return new FuncResult<T>() { Content = content, Message = message, StatusCode = statusCode, Success = false };
        }
    }
    /// <summary>
    /// 返回信息
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class FuncResult<T> : FuncResult
    {
        /// <summary>
        /// 
        /// </summary>
        public T Content { get; set; }
    }
}
